# -*- coding:utf-8 -*-
import httplib, urllib, json
 
headers = {"Content-Type":"application/x-www-form-urlencoded",   
                   "Connection":"Keep-Alive","Referer":"http://127.0.0.1/"};   
conn = httplib.HTTPConnection("127.0.0.1", 8080);   
baseurl = '/message'
post_item = {}
post_item['code'] = '5aSn5rC054mbOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2'
post_item['message_id'] = 10000
post_item['type'] = 'delete'
params = urllib.urlencode(post_item); 
myurl = baseurl
conn.request(method="POST", url=myurl, body=params, headers=headers);
#返回处理后的数据   
response = conn.getresponse(); 
#判断是否提交成功   
print response.status
print json.dumps(json.loads(response.read()), indent = 4)

post_item = {}
post_item['code'] = '5aSn5rC054mbOjhhYWVlYWVkNDk0NmExZmQxZTBkYmY5MTNmZWUxMDI2'
post_item['type'] = 'clear'
params = urllib.urlencode(post_item); 
myurl = baseurl
conn.request(method="POST", url=myurl, body=params, headers=headers);
#返回处理后的数据   
response = conn.getresponse(); 
#判断是否提交成功   
print response.status
print json.dumps(json.loads(response.read()), indent = 4)

conn.close();
